import { createRouter, createWebHistory } from 'vue-router'
import Layout from '@/layout'

export const constantRoutes = [
  // 大屏可视化 母版入口地址
  {
    path: '/mother-set/:status/:id', //  id: 页面id status页面状态
    name: 'mother-set',
    component: () => import('@/views/mother-set/index'),
    hidden: true,
    children: [
      {
        path: 'mother-set-child/:routeName?',
        name: 'mother-set-child',
        component: () => import('@/views/mother-set/PageChild.vue')
      }
    ]
  },
  {
    path: '/v-motherboard:pageId?',
    name: 'motherboard',
    component: () => import('@/views/motherboard/pages'),
    hidden: true,
    // 后期获取接口添加路由
    children: [
      {
        path: 'motherboard-child:routeName?',
        name: 'motherboard-child',
        component: () => import('@/views/motherboard/pages/Child.vue')
      }
    ]
  },
  // 管理端代码
  {
    path: '/',
    component: Layout,
    redirect: '/index',
    meta: {
      title: '首页',
      icon: 'home',
      affix: true
    },
    children: [
      {
        path: '/index',
        name: 'Index',
        component: () => import('@/views/index'),
        meta: {
          title: '首页',
          icon: 'home',
          affix: true
        }
      }
    ]
  },
  {
    path: '/page-manage',
    component: Layout,
    children: [
      {
        path: '',
        name: 'PageManage',
        component: () => import('@/views/management/pages/page-manage'),
        meta: {
          title: '页面管理',
          icon: 'user'
        }
      }
    ]
  },
  {
    path: '/motherboard-manage',
    component: Layout,
    children: [
      {
        path: '',
        name: 'MotherboardManage',
        component: () => import('@/views/management/pages/motherboard-manage/index.vue'),
        meta: {
          title: '母版管理',
          icon: 'user'
        }
      }
    ]
  },
  {
    path: '/component-manage',
    component: Layout,
    children: [
      {
        path: '',
        name: 'ComponentManage',
        component: () => import('@/views/management/pages/component-manage'),
        meta: {
          title: '组件管理',
          icon: 'user'
        }
      }
    ]
  },
  {
    path: '/page-configuration/:id',
    name: 'PageConfiguration',
    component: () => import('@/views/management/pages/page-manage/PageConfiguration'),
    meta: {
      title: '配置页面'
    },
    hidden: true
  },
  {
    path: '/:pathMatch(.*)',
    redirect: '/404',
    hidden: true
  },

  {
    path: '/demo',
    name: 'demo',
    component: () => import('@/views/demo'),
    hidden: true
  },
  {
    path: '/deng',
    name: 'deng',
    component: () => import('@/views/demo/deng'),
    hidden: true
  },
  {
    path: '/yang',
    name: 'yang',
    component: () => import('@/views/demo/yang'),
    hidden: true
  },
  {
    path: '/liu',
    name: 'liu',
    component: () => import('@/views/demo/liu'),
    hidden: true
  },
  {
    path: '/403',
    name: '403',
    component: () => import('@/views/403'),
    hidden: true
  },
  {
    path: '/404',
    name: '404',
    component: () => import('@/views/404'),
    hidden: true
  }
]
export const asyncRoutes = []

// console.warn('__MICRO_APP_BASE_ROUTE__', window.__MICRO_APP_BASE_ROUTE__)
// console.warn('BASE_URL', process.env.BASE_URL)

const router = createRouter({
  history: createWebHistory(window.__MICRO_APP_BASE_ROUTE__ || process.env.BASE_URL),
  routes: constantRoutes
})

export default router
